export default class Cache {
    constructor({ expire = 3600 }) {
        this.expire = new Date().getTime() + expire * 1000;
    }
    set(key, value) {
        let data = { expire: this.expire, value };
        uni.setStorageSync(key, data);
    }
    forever(key, value) {
        let expire = new Date().getTime() + 9999999999 * 1000;
        let data = { expire, value };
        uni.setStorageSync(key, data);
    }
    has(key) {
        let time = new Date().getTime();
        let data = uni.getStorageSync(key);
        if (data != '') {
            if (time > data.expire) {
                uni.removeStorageSync(key);
                return false;
            }
            return true;
        }
        return false;
    }
    get(key) {
        if (this.has(key)) {
            return uni.getStorageSync(key).value;
        }
        return null;
    }
    del(key) {
        uni.removeStorageSync(key);
    }
}
